#include "systemnotification.h"

#include <QApplication>
#include <QUrl>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusInterface>

SystemNotification::SystemNotification(QObject *parent) : QObject(parent)
{
    m_interface = new QDBusInterface(QStringLiteral("org.freedesktop.Notifications"),
                                     QStringLiteral("/org/freedesktop/Notifications"),
                                     QStringLiteral("org.freedesktop.Notifications"),
                                     QDBusConnection::sessionBus(),
                                     this);
}

void SystemNotification::sendMessage(const QString &title, const QString &text,const int timeout)
{
    QList<QVariant> args;
    QMap<QString, QVariant> hintsMap;
    hintsMap.insert("sound-name","screen-capture"); //添加声音

    args << tr("Screencap")              // appname
         << static_cast<unsigned int>(0) // id
         << "kylin-screencap"            // icon
         << title                        // summary
         << text                         // body
         << QStringList()                // actions
         << hintsMap                     // hints
         << int()-1;                     // timeout
    m_interface->callWithArgumentList(QDBus::AutoDetect, QStringLiteral("Notify"), args);

}
